View Issue Details

IDProjectCategoryView StatusLast Update
0001659K18X001.00 SKB SWANSWpublic2023-03-28 09:42
Reporter(ALTech) Sangmin Choi Assigned To(ALTech) Sangmin Choi Due Date2023-02-20 19:00
PrioritynormalSeveritys4-minorReproducibilityN/A
Status closedResolutionfixed 
Summary0001659: Please apply this patch from BTVSBOX-629.
DescriptionHi, Jason,

Please apply this patch from BTVSBOX-629.

Commit Message
[BTVSBOX-629] Adjust STC offset to prevent Audio drop for the case there is big PTS gab between Audio and Video

syna-release/ampsdk
BTVSBOX-629-PCR-offset.patch

Thank you.
TagsNo tags attached.
Attach Tags

Users monitoring this issue

User List (SW) Dean Chiang , (SW) Jim Chen

Activities

(ALTech) Sangmin Choi

2023-02-17 15:26

developer  

BTVSBOX-629-PCR-offset.patch (5,369 bytes)   
diff --git a/amp/src/ddl/comp_clk/source/clk_avsync.c b/amp/src/ddl/comp_clk/source/clk_avsync.c
index a80fa15..0e094b6 100755
--- a/amp/src/ddl/comp_clk/source/clk_avsync.c
+++ b/amp/src/ddl/comp_clk/source/clk_avsync.c
@@ -938,6 +938,33 @@ BOOL check_pause_pts(AVSYNC_MGR *pSyncMgr, SYNC_STREAM *pStream, BD_INFO *pBDInf
     return ret;
 }
 
+AMP_CLK_ACT check_sim_out_pts(AVSYNC_MGR *pSyncMgr, SYNC_STREAM *pStream, BD_INFO *pBDInfo)
+{
+    UINT uiRange = 900000;
+    AMP_CLK_ACT eAct = AMP_CLK_DISP;
+
+    if (check_pts_range(pBDInfo->m_uiPtsStart,
+                        pSyncMgr->m_uiMaxPTS,
+                        uiRange, uiRange,
+                        FALSE) == AMP_CLK_DISP) {
+        if (!pSyncMgr->m_fAllStreamsReady) {
+            eAct = AMP_CLK_HOLD;
+        } else if (GET_PTS_VAL64(pBDInfo->m_uiPtsStart) <
+            GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS)) {
+            eAct = AMP_CLK_DROP;
+        }
+    } else {
+        // Disable simultaneous output
+        AVSH("[%d]CHECK_%s PTS:[0x%09llX][%lld],STC:[0x%09llX][%lld], [OPT]SIM_OUTPUT(DISABLED!)!",
+            pSyncMgr->m_pAVClock->m_uiClockID, pStream->m_szName,
+            GET_PTS_VAL64(pBDInfo->m_uiPtsStart), GET_PTS_VAL64(pBDInfo->m_uiPtsStart),
+            GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS), GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS));
+        pSyncMgr->m_fSimOut = FALSE;
+    }
+
+    return eAct;
+}
+
 VOID local_playback_res_change(AVSYNC_MGR *pSyncMgr, BOOL fDone)
 {
     if (!fDone) {
@@ -3175,7 +3202,7 @@ VOID dtv_check_pcr(AVSYNC_MGR *pSyncMgr, UINT64 pcr, UINT64 stc)
     diff_local_clk = PTS64_DIFF_WRAP(stc, pSyncMgr->m_recent_local_clk);
     freq_diff = diff_local_clk - diff_src_clk;
 
-    AVSM("[AVS]%s(pcr:0x%x(%d), stc:0x%x(%d), diff: phase:%lld(%lld)"
+    AVSI("[AVS]%s(pcr:0x%x(%d), stc:0x%x(%d), diff: phase:%lld(%lld)"
          " freq:%lld(%lld))", __FUNCTION__,
         (UINT32)pcr, (UINT32)PTS64_DIFF_WRAP(pcr, last_pcr),
         (UINT32)stc, (UINT32)PTS64_DIFF_WRAP(stc, last_stc),
@@ -3640,7 +3667,7 @@ VOID dtv_check_avsync(AVSYNC_MGR *pSyncMgr)
             } else if (IS_PTS_VALID64(pSyncMgr->m_uiTimeFirstSample)) {
                 UINT64 t = avclock_get_wall64(pSyncMgr->m_pAVClock, FALSE);
                 UINT64 diff = t - GET_PTS_VAL64(pSyncMgr->m_uiTimeFirstSample);
-                if (diff > 90000) {
+                if ((diff > 90000 && pSyncMgr->m_fAllStreamsReady) || diff > 900000) {
                     pSyncMgr->m_sPsp.m_uiPcr = pSyncMgr->m_uiMinPTS;
                     pSyncMgr->m_sPsp.m_uiStc = t;
                     pSyncMgr->m_uiStartSTC = GET_PTS_VAL64(pSyncMgr->m_sPsp.m_uiPcr) -
@@ -3715,12 +3742,8 @@ HRESULT dtv_check_video_pts(AVSYNC_MGR *pSyncMgr,
     }
 
     if (pSyncMgr->m_fSimOut && pSyncMgr->m_eSyncStatus == SYNC_LOCKING) {
-        if (!pSyncMgr->m_fAllStreamsReady) {
-            eAct = AMP_CLK_HOLD;
-            goto _Exit;
-        } else if (GET_PTS_VAL64(pBDInfo->m_uiPtsStart) <
-            GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS)) {
-            eAct = AMP_CLK_DROP;
+        eAct = check_sim_out_pts(pSyncMgr, pStream, pBDInfo);
+        if (eAct != AMP_CLK_DISP) {
             goto _Exit;
         }
     }
@@ -3954,12 +3977,8 @@ HRESULT dtv_check_audio_pts(AVSYNC_MGR *pSyncMgr,
     }
 
     if (pSyncMgr->m_fSimOut && pSyncMgr->m_eSyncStatus == SYNC_LOCKING) {
-        if (!pSyncMgr->m_fAllStreamsReady) {
-            eAct = AMP_CLK_HOLD;
-            goto _Exit;
-        } else if (GET_PTS_VAL64(pBDInfo->m_uiPtsStart) <
-            GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS)) {
-            eAct = AMP_CLK_DROP;
+        eAct = check_sim_out_pts(pSyncMgr, pStream, pBDInfo);
+        if (eAct != AMP_CLK_DISP) {
             goto _Exit;
         }
     }
@@ -4195,7 +4214,7 @@ VOID live_net_policy_init(AVSYNC_MGR *pSyncMgr)
 
     pSyncMgr->m_fPcrEnabled     = TRUE;
     pSyncMgr->m_fPcrAdj         = TRUE;
-    pSyncMgr->m_iPcrOffset      = 27000;
+    pSyncMgr->m_iPcrOffset      = 27000*4;
     pSyncMgr->m_uiPcrAdjThresh  = 300;
     pSyncMgr->m_iPcrOrigOffset  = pSyncMgr->m_iPcrOffset;
 
@@ -5210,6 +5229,12 @@ HRESULT avsync_mgr_new_pcr(AVSYNC_MGR *pSyncMgr, UINT64 uiPcr, UINT64 uiStc, UIN
 
     dtv_check_pcr(pSyncMgr, uiPcr, uiClk);
 
+    if (!pSyncMgr->m_fPcrValid ){
+        AVSH("[PCR]PCR:0x%08x, LastPCR:0x%08x, P-LP:%6lld, T-LT:%6d, [%d][%d]",
+            (INT32)pcr, (INT32)last_pcr, (pcr - last_pcr),
+            (stc - last_stc), pSyncMgr->m_fPcrDiscPending,
+            pSyncMgr->m_uiPcrContinueCnt);
+    }
     AVSI("[PCR]PCR:0x%08x, LastPCR:0x%08x, P-LP:%6lld, T-LT:%6d, [%d][%d]",
          (INT32)pcr, (INT32)last_pcr, (pcr - last_pcr),
          (stc - last_stc), pSyncMgr->m_fPcrDiscPending,
@@ -5238,8 +5263,8 @@ HRESULT avsync_mgr_new_pcr(AVSYNC_MGR *pSyncMgr, UINT64 uiPcr, UINT64 uiStc, UIN
         SET_PTS_VALID64(pSyncMgr->m_uiMinPCR);
     }
 
-    if (!pSyncMgr->m_fPcrValid && last_pcr && pcr != last_pcr &&
-        ((pcr - last_pcr) < (stc - last_stc))) {
+    if (!pSyncMgr->m_fPcrValid && last_pcr && pcr != last_pcr /*  ){ */
+         && ((pcr - last_pcr) < (stc - last_stc))) {
         pSyncMgr->m_fPcrValid = TRUE;
         AVSH("[AVS]PCR VALID(PCR:0x%x)!", pSyncMgr->m_sPsp.m_uiPcr);
         return SUCCESS;
BTVSBOX-629-PCR-offset.patch (5,369 bytes)   

(SW) Dean Chiang

2023-02-18 11:12

developer   ~0012246

Hi Sangmin,

Done.
2023-02-18 11:10:26 | dean.ty.chiang@mai.. | c965de7 | syna-release/ampsdk | [BTVSBOX-629] Adjust STC offset to prevent Audio drop for the case there is big PT

Thank you.
Dean Chiang

(SW) Dean Chiang

2023-02-18 11:28

developer   ~0012247

Reminder sent to: (ALTech) Sangmin Choi

(ALTech) Sangmin Choi

2023-03-27 16:13

developer   ~0012651

Hello, Jason,

There is a side effect that the channel change speed is slow about 200~300ms after apply this patch.
Synaptics guide us to modify source code as follows.

-pSyncMgr->m_iPcrOffset = 27000*4;
+pSyncMgr->m_iPcrOffset = 27000;

Could you please push this change?
Please insert "[BAIS2-801]" as prefix for commit message.

And, SKB is going to make TAG tomorrow, so please modify it until today.

Thank you.
Sangmin Choi.

(SW) Jason Ling

2023-03-27 17:11

developer   ~0012655

Hi Sangmin,

Done

2023-03-27 17:10:04 | jason.tf.ling@fii-.. | 40a6ec0c | syna-release/ampsdk | [BAIS2-801] Adjust STC offset to prevent Audio drop for t

Thanks
Jason

(ALTech) Sangmin Choi

2023-03-28 09:42

developer   ~0012659

Dear Jason,

Thank you!

Issue History

Date Modified Username Field Change
2023-02-17 15:26 (ALTech) Sangmin Choi New Issue
2023-02-17 15:26 (ALTech) Sangmin Choi Status new => assigned
2023-02-17 15:26 (ALTech) Sangmin Choi Assigned To => (SW) Jason Ling
2023-02-17 15:26 (ALTech) Sangmin Choi File Added: BTVSBOX-629-PCR-offset.patch
2023-02-17 15:26 (ALTech) Sangmin Choi Issue Monitored: (SW) Dean Chiang
2023-02-17 15:26 (ALTech) Sangmin Choi Issue Monitored: (SW) Jim Chen
2023-02-17 19:06 (SW) Jason Ling Assigned To (SW) Jason Ling => (SW) Dean Chiang
2023-02-18 11:12 (SW) Dean Chiang Note Added: 0012246
2023-02-18 11:28 (SW) Dean Chiang Note Added: 0012247
2023-02-18 11:29 (SW) Dean Chiang Assigned To (SW) Dean Chiang => (ALTech) Sangmin Choi
2023-02-21 12:29 (ALTech) Sangmin Choi Status assigned => closed
2023-02-21 12:29 (ALTech) Sangmin Choi Resolution open => fixed
2023-03-27 16:13 (ALTech) Sangmin Choi Assigned To (ALTech) Sangmin Choi => (SW) Jason Ling
2023-03-27 16:13 (ALTech) Sangmin Choi Status closed => feedback
2023-03-27 16:13 (ALTech) Sangmin Choi Resolution fixed => reopened
2023-03-27 16:13 (ALTech) Sangmin Choi Due Date 2023-02-20 16:24 => 2023-02-20 19:00
2023-03-27 16:13 (ALTech) Sangmin Choi Note Added: 0012651
2023-03-27 17:11 (SW) Jason Ling Assigned To (SW) Jason Ling => (ALTech) Sangmin Choi
2023-03-27 17:11 (SW) Jason Ling Status feedback => resolved
2023-03-27 17:11 (SW) Jason Ling Resolution reopened => fixed
2023-03-27 17:11 (SW) Jason Ling Note Added: 0012655
2023-03-28 09:42 (ALTech) Sangmin Choi Status resolved => closed
2023-03-28 09:42 (ALTech) Sangmin Choi Note Added: 0012659